Open feat(terraform): Add TF parity updates for v0.4.0#48
Open feat(terraform): Add TF parity updates for v0.4.0#48kaleko merged 8 commits intoawslabs:mainfrom
Conversation
|
Planning to incorporate private VPC support before merging |
|
Looks good for merging. BTW the next release might be 0.4.0 instead of 0.3.2 because there are some fairly major additions |
|
Updated with VPC mode and some additional improvements |
|
Latest scan for commit: Security Scan ResultsScan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies: Column Explanations: Severity Levels (S/C/H/M/L/I):
Other Columns:
Scanner Results:
Severity Thresholds (Thresh Column):
Threshold Source: Values in parentheses indicate where the threshold is configured:
Statistics calculation:
Detailed FindingsShow 94 actionable findingsFinding 1: B602
Description: Code Snippet: Finding 2: CKV_AWS_300
Description: Code Snippet: Finding 3: CKV_AWS_300
Description: Code Snippet: Finding 4: CKV_AWS_119
Description: Code Snippet: Finding 5: CKV_AWS_338
Description: Code Snippet: Finding 6: CKV_AWS_158
Description: Code Snippet: Finding 7: CKV_AWS_50
Description: Code Snippet: Finding 8: CKV_AWS_117
Description: Code Snippet: Finding 9: CKV_AWS_272
Description: Code Snippet: Finding 10: CKV_AWS_116
Description: Code Snippet: Finding 11: CKV_AWS_173
Description: Code Snippet: Finding 12: CKV_AWS_115
Description: Code Snippet: Finding 13: CKV_AWS_237
Description: Code Snippet: Finding 14: CKV_AWS_73
Description: Code Snippet: Finding 15: CKV_AWS_120
Description: Code Snippet: Finding 16: CKV_AWS_338
Description: Code Snippet: Finding 17: CKV_AWS_158
Description: Code Snippet: Finding 18: CKV_AWS_308
Description: Code Snippet: Finding 19: CKV_AWS_338
Description: Code Snippet: Finding 20: CKV_AWS_158
Description: Code Snippet: Finding 21: CKV_AWS_50
Description: Code Snippet: Finding 22: CKV_AWS_117
Description: Code Snippet: Finding 23: CKV_AWS_272
Description: Code Snippet: Finding 24: CKV_AWS_116
Description: Code Snippet: Finding 25: CKV_AWS_115
Description: Code Snippet: Finding 26: CKV_AWS_338
Description: Code Snippet: Finding 27: CKV_AWS_158
Description: Code Snippet: Finding 28: CKV_AWS_50
Description: Code Snippet: Finding 29: CKV_AWS_117
Description: Code Snippet: Finding 30: CKV_AWS_272
Description: Code Snippet: Finding 31: CKV_AWS_116
Description: Code Snippet: Finding 32: CKV_AWS_115
Description: Code Snippet: Finding 33: CKV_AWS_149
Description: |
kaleko
left a comment
There was a problem hiding this comment.
Issues to flag
-
backend_vpc_subnet_idsvalidation is a no-op — The validation length(var.backend_vpc_subnet_ids) == 0 || length(var.backend_vpc_subnet_ids) >= 1 is always true. The real validation is in the check block in locals.tf, which is correct, but this variable-level validation should either be removed or fixed to something meaningful. -
Missing docs/TERRAFORM_DEPLOYMENT.md — The README references ../docs/TERRAFORM_DEPLOYMENT.md but I don't see it in the diff. Is it in a separate PR, or was it missed?
-
Can we include some notion of FAST-TF version? I remember discussing that with you but can't find the slack messages. Both CDK and TF should start at 0.4.0
cc: @kunanit
I've made updates to address feedback:
|
Summary
Sync Terraform infrastructure with CDK state in preparation for v0.4.0 release, which includes OAuth2 Credential Provider changes (PR #38) and VPC deployment mode (MR !41).
Version
Changes (Infra parity)
OAuth2 Credential Provider Integration
Deploys OAuth2 Credential Provider infrastructure to enable Runtime → Gateway authentication using Token Vault pattern.
CDK change references
Components
oauth2_provider.tf) that manages OAuth2 Credential Provider lifecycle simulating CloudFormation Custom Resource patternruntime.tf):runtime.tf):GATEWAY_CREDENTIAL_PROVIDER_NAMEenvironment variableallowed_audience→allowed_clients(parameter name change)Variables/Outputs:
Implementation Notes:
The CDK implementation uses CloudFormation's Custom Resource pattern with the
Providerconstruct, which automatically handles the full CRUD lifecycle (Create/Update/Delete). In Terraform, we replicate this functionality using anull_resourcewithlocal-execprovisioner that invokes the same Lambda function directly. The Lambda code is shared frominfra-cdk/lambdas/oauth2-provider/index.pywith a transport-agnostic design that supports both CloudFormation's callback protocol and direct invocation.The Terraform implementation only uses Create and Delete events - we don't need explicit Update logic because changes to the trigger values (client ID, discovery URL, etc.) automatically force recreation of the null_resource, which re-invokes the Lambda with updated configuration. The Lambda itself has full CRUD support to maintain compatibility with CDK's CloudFormation lifecycle.
VPC Deployment Mode
Aligns Terraform VPC deployment support with CDK's VPC deployment mode (MR !41), ensuring consistent terminology and configuration.
CDK change references
Components
backend_vpc_id,backend_vpc_subnet_ids,backend_vpc_security_group_idslocals.tf):checkblock validates that VPC fields are provided whenbackend_network_mode = "VPC"backend_vpc_security_group_idsis omitted (HTTPS self-referencing ingress + all-traffic egress)Variables/Outputs:
backend_vpc_id,backend_vpc_subnet_ids,backend_vpc_security_group_ids)backend_network_modeaccepts "PUBLIC" (default) or "VPC"Implementation Notes:
The Terraform VPC mode uses the
network_mode_configblock within theaws_bedrockagentcore_agent_runtimeresource'snetwork_configuration, which maps directly to the AWS API. Unlike CDK, which can create a default security group when none is provided, the Terraform provider requires explicitsecurity_groupsin thenetwork_mode_configblock. This difference is documented in the variable descriptions and README.Variable Interface Cleanup (CDK Parity)
Streamlines the Terraform variable interface to match the CDK
config.yamlsurface. Variables that don't exist in CDK's configuration are either removed or converted to module-internal locals.Removed variables (7):
aws_regionbackend_agent_nameStrandsAgent)backend_memory_event_expiry_days30)callback_urlspassword_minimum_length8)environmentdefault_tagstagsdefault_tagsComponents
tags = var.tagslines from resources (inherited via providerdefault_tags)local.common_tagsto fixed tags (Project, ManagedBy, Repository)locals.tf):agent_name,memory_event_expiry_daysmain.tf):default_callback_urls,password_minimum_lengthbuild-and-push-image.sh: region resolved from AWS SDK chain instead of tfvarsterraform.tfvars.example: removed deleted variables, added guidance for region and tagsRemaining user-facing variables (8):
stack_name_base,admin_user_email,backend_pattern,backend_deployment_type,backend_network_mode,backend_vpc_id,backend_vpc_subnet_ids,backend_vpc_security_group_idsOutput Pruning (CDK Parity)
Removed 9 TF-only outputs that have no CDK
CfnOutputcounterpart and are not consumed by any deployment or test scripts.Removed outputs:
cognito_user_pool_arncognito_hosted_ui_urlmemory_idmemory_arnecr_repository_urlbuild-and-push-image.shconstructs ECR URL independentlyagent_code_bucketdeployment_typefeedback_api_idfeedback_table_namefeedback_lambda_arnAlso removed
cognito_loginfield fromdeployment_summary(referenced prunedhosted_ui_url).Remaining outputs (19): All match a CDK
CfnOutputexport or are consumed by deployment/test scripts (deploy-frontend.sh/py,test-agent.py,test-oauth2-auth.py).Other Changes
AWS Provider Version Constraint
During testing, discovered AWS Terraform provider regression introduced in v6.35.0 that breaks Gateway Target resources with nested
input_schema.propertyblocks. Provider cannot deserialize schema during state refresh. This is fixed in v6.35.1 .Components
.terraform.lock.hclto v6.35.1 (latest working version)Implementation Notes:
6.22is the minimum AWS provider version that supports thecode_configurationsource type block in the AgentCore Runtime resource, which is used for the "zip" deployment type, which determined the minimum version constraint.Testing
test-oauth2-auth.py)terraform validate- [PASS]terraform fmt -check -recursive- [PASS]Documentation
Terraform Deployment Guide (
docs/TERRAFORM_DEPLOYMENT.md)Created a dedicated Terraform deployment guide in
docs/that mirrors the structure of the CDKdocs/DEPLOYMENT.md:infra-terraform/README.md Refactored
Slimmed down content to focus on design:
Other Documentation